package com.annotation.hw.hw2;

import java.lang.reflect.Method;
import java.lang.reflect.Parameter;

/**
 * @author bin
 * @date 2025 - 03 -28
 **/
public class Util {
    public int value(Class<?> clazz) throws Exception {
        // 获取方法
        Method method = Sum.class.getMethod("getSum", int.class);
        Parameter[] parameters = method.getParameters();
        for (Parameter parameter : parameters) {
            if (parameter.isAnnotationPresent(myAnnotation.class)) {
                myAnnotation annotation = parameter.getAnnotation(myAnnotation.class);
                return annotation.value();
            }
        }
        return 0;
    }
}
